package thread;

public class SyncDemo {
    public static void main(String[] args) {
        StringBuffer sb = new StringBuffer();
        StringBuilder sbi = new StringBuilder();
        Thread t1 = new Thread()
        {
            public void run() {
                for(int i = 0 ; i  < 1000 ; i++)
                {
                    sbi.append("abc");
                }
            };
        };
        Thread t2 = new Thread()
        {
            public void run() {
                for(int i = 0 ; i < 1000; i++)
                {
                    sbi.append("123");
                }
            };
        };
        t1.start();

        t2.start();

        try {
            Thread.sleep(1000);
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        System.out.println(sbi.length());
        System.out.println(sbi);
    }

}
